﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using CabLib;
using WSPDocumentBuilder_WPF.Managers;
using System.ComponentModel;

namespace WSPDocumentBuilder_WPF
{
    /// <summary>
    /// Logique d'interaction pour MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void OnWspDropped(object sender, DragEventArgs e)
        {
            // Récupération de la liste des fichiers
            string[] droppedFilenames = DragDropManager.GetDroppedFilenames(e.Data);

            // Génération de la liste des fichiers
            BackgroundWorker bgWorker = new BackgroundWorker();
            bgWorker.DoWork += new DoWorkEventHandler(OnProcessGeneration);
            bgWorker.RunWorkerAsync(droppedFilenames);
            
        }

        private void OnProcessGeneration(object sender, DoWorkEventArgs e)
        {
            WSPDocumentBuilderFacade.GenerateDocumentation(e.Argument as string[], NotifyProgress);
        }

        private void NotifyProgress(string message)
        {
            this.txtProgress.Text += Environment.NewLine + message;
        }
    }
}
